package com.niit.web.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.niit.bean.Classify;
import com.niit.bean.Question;
import com.niit.service.ClassifyService;
import com.niit.service.QuestionService;
import com.niit.service.impl.ClassifyServiceImpl;
import com.niit.service.impl.QuestionServiceImpl;
import com.niit.utils.Page;
import com.niit.utils.WebKit;

@WebServlet("/ShowQuestionController")
public class ShowQuestionController extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String pagenum = request.getParameter("curPage");
		QuestionService qs = new QuestionServiceImpl();
		ClassifyService cs = new ClassifyServiceImpl();
		List<Classify> list = cs.findAll();
		Page<Question> page = qs.getPage(pagenum, WebKit.getServletURI(request));
		request.setAttribute("list", list);
		request.setAttribute("page", page);
		request.getRequestDispatcher("/jsp/admin/load/them1.jsp").forward(request, response);
		
	}

}
